<template>
  <div class="news_container">
    <van-tabs @click="onClick" animated class="tabs">
      <van-tab title="日报" name="日报">
        <div class="hotNewList">
          <van-list v-model="loading" :finished="finished" finished-text="暂无更多数据" @load="onLoad">
            <div class="item clearfix" v-for="item in dailyList " :key="item.id" @click="details(item)">
              <div class="left">
                <div class="date">
                  <h2>
                    {{item.createTime.substring(8,10)}}
                  </h2>
                  <p> {{item.createTime.substring(0,7)}}</p>
                </div>
              </div>
              <div class="right">
                <div class="content">
                  <p class="name">{{ item.title}}</p>
                  <span class="time">{{ item.updateTime}}</span>
                </div>
              </div>
            </div>
          </van-list>
        </div>

      </van-tab>
      <van-tab title="周报" name="周报">
        <div class="weeklist">
          <ul class="my-swipe weeklist">
            <li :key="index" v-for="(item,index) in weekList" @click="pdf_details(item)">
              <img :src="item.fakuImg" alt="">
              <p class="text-1 name">{{item.title}}</p>
            </li>
          </ul>
        </div>
      </van-tab>
    </van-tabs>

  </div>
</template>
<script>
import path from '@/network'
export default {
  name: 'App',
  data () {
    return {
      count: 0,
      weekList: [],
      total: 0,
      pagesize: 10,
      currentPage: 1,
      dailyList: [],
      pagemax: '',
      dailyId: '',
      weekId: '',

      loading: false,
      finished: false,

    };
  },

  created () {
  },
  beforeDestroy () {
  },

  mounted () {
    this.getSecondType(this.$route.query.firstId)

  },
  methods: {
    onClick (name, title) {
      console.log(title);
    },

    pdf_details: function (item) {
      this.$router.push({ name: 'pdf_details', query: { secondId: item.id, firstId: this.$route.query.firstId, title:'详情' } })
    },

    details: function (item) {
      this.$router.push({ name: 'details', query: { secondId: item.id, type: 2, title:'详情' } })
    },
    //获取list
    getSecondType (id) {
      path.getSecondType(
        id
      ).then(res => {
        if (res.success === 0) {
          this.dailyName = res.rows[0].name;
          this.weekName = res.rows[1].name;

          this.dailyId = res.rows[0].id;
          this.weekId = res.rows[1].id;

          this.getLawList(this.dailyId)
          this.getLawList(this.weekId)
        }
      })
    },

    //获取list
    getLawList (id) {
      path.getLawList(
        this.currentPage,
        this.pagesize,
        id
      ).then(res => {
        if (res.success === 0) {
          this.pagemax = res.rows.total;
          if (id == 3) {
            this.dailyList = res.rows
            this.total = (res.total / this.pagesize);

          } else {
            this.tableCount = res.total;
            console.log(this.tableCount)
            if (this.currentPage == 1) {
              this.weekList = res.rows
            } else {
              this.weekList = this.weekList.concat(res.rows);

            }

          }
        }

      })
    },
    onLoad () {
      // if (this.activeId) {
      //   this.getLiveList(this.activeId)
      // }
    }

  }

}
</script>